package com.edfu.core.coursemgt.persistence.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.edfu.core.identitymgt.persistence.entity.UserEntity;
import com.edfu.core.institutemgt.persistence.entity.BatchEntity;


@Entity
@Table(name="courseofferinginstance", uniqueConstraints=@UniqueConstraint(columnNames={"courseoffering_id", "batch_id"}))
public class CourseOfferingInstanceEntity implements ICourseMgtEntity {
	private long id;
	private BatchEntity batch;
	private CourseOfferingEntity courseOffering;
	//private AcadSemEntity semester;
	private boolean subscribe ;
	private boolean unsubscribe ;
	private String contentDirectory;
	private Set<LessonInstanceEntity> lessons;
	private String status ="Active";
	private UserEntity owner;
	//private RoomEntity room;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	@ManyToOne
	@JoinColumn(name = "courseoffering_id", nullable = false)
	public CourseOfferingEntity getCourseOffering() {
		return courseOffering;
	}
	public void setCourseOffering(CourseOfferingEntity courseOffering) {
		this.courseOffering = courseOffering;
	}
	
//	@ManyToOne
//	@JoinColumn(name = "semester_id", nullable = false)
//	public AcadSemEntity getSemester() {
//		return semester;
//	}
//	public void setSemester(AcadSemEntity semester) {
//		this.semester = semester;
//	}
	public boolean isSubscribe() {
		return subscribe;
	}
	public void setSubscribe(boolean subscribe) {
		this.subscribe = subscribe;
	}
	public boolean isUnsubscribe() {
		return unsubscribe;
	}
	public void setUnsubscribe(boolean unsubscribe) {
		this.unsubscribe = unsubscribe;
	}
	@ManyToOne
	@JoinColumn(name="batch_id", nullable=false)
	public BatchEntity getBatch() {
		return batch;
	}
	public void setBatch(BatchEntity batch) {
		this.batch = batch;
	}
	public String getContentDirectory() {
		return contentDirectory;
	}
	public void setContentDirectory(String contentDirectory) {
		this.contentDirectory = contentDirectory;
	}
	
	@OneToMany(mappedBy = "courseOfferingInstance", fetch= FetchType.EAGER, cascade=CascadeType.ALL)
	public Set<LessonInstanceEntity> getLessons() {
		return lessons;
	}
	public void setLessons(Set<LessonInstanceEntity> lessons) {
		this.lessons = lessons;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	
	@ManyToOne
	@JoinColumn(name="owner_id", nullable=false)
	public UserEntity getOwner() {
		return owner;
	}
	public void setOwner(UserEntity owner) {
		this.owner = owner;
	}
	
//	@ManyToOne
//	@JoinColumn(name="room_id", nullable=true)
//	public RoomEntity getRoom() {
//		return room;
//	}
//	public void setRoom(RoomEntity room) {
//		this.room = room;
//	}	
	
}
